package com.blog.wu.myblog.restful;

import com.blog.wu.myblog.entity.UserInfo;
import com.blog.wu.myblog.service.UserInfoService;
import com.blog.wu.myblog.util.PageBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author wuyanshen
 * @Date 2018-12-04 3:44 PM
 * @Discription 提供给前端的用户模块API
 */
@Api(tags = "用户模块",description = "UserRestController")
@RestController
@RequestMapping("api/user")
public class UserRestController {
    @Autowired
    private UserInfoService userInfoService;

    @ApiOperation(httpMethod = "GET",value = "查询所有用户接口",notes = "查询所有用户接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userName",value = "用户姓名(支持模糊查询)",required = false,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "pageNo",value = "第几页",required = true,dataType = "String",paramType = "query")
    })
    @RequestMapping(value = "list",method = RequestMethod.GET)
    @ResponseBody
    public Result userList(@Param("userName")String userName, @Param("pageNo")String pageNo){
        UserInfo userInfo = new UserInfo();
        userInfo.setUserName(userName);
        PageBean<UserInfo> pageBean = userInfoService.findPage(userInfo, Integer.parseInt(pageNo));
        return Result.Success(pageBean.getList(),"请求成功");
    }
}
